package com.ccrfid.rmc6.resource.poi;

import com.ccrfid.rmc6.appconfig.auth.Secured;
import com.ccrfid.rmc6.appconfig.exception.pojo.AppException;
import com.ccrfid.rmc6.entity.poi.PoiLineEntity;
import com.ccrfid.rmc6.service.poi.PoiLineService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

@Secured
@Path("lines")
@Produces(MediaType.APPLICATION_JSON)
public class PoiLineResource {

    @Autowired
    private PoiLineService poiLineService;

    //1.获取全部隔离线
    @GET
    @Path("all")
    public List<PoiLineEntity> getAllLines(@QueryParam("floorNumber") Integer floorNumber) {
        return poiLineService.getAllLines(floorNumber);
    }

    //2.获取某个隔离线
    @GET
    @Path("{id:[0-9]*}")
    public PoiLineEntity getLineById(@PathParam("id") Long id) throws AppException {
        return poiLineService.getLineById(id);
    }

    //3.新增隔离线
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public PoiLineEntity createLine(PoiLineEntity entity) throws AppException {
        return poiLineService.createLine(entity);
    }

    //4.修改隔离线
    @PUT
    @Path("{id:[0-9]*}")
    @Consumes(MediaType.APPLICATION_JSON)
    public PoiLineEntity updateLine(@PathParam("id") Long id, PoiLineEntity entity) throws AppException {
        return poiLineService.updateLine(id, entity);
    }

    //5.删除隔离线
    @DELETE
    @Path("{id:[0-9]*}")
    public boolean deleteLineById(@PathParam("id") Long id) throws AppException {
        return poiLineService.deleteLineById(id);
    }
}
